home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1999 Spring / macformat-077.iso / Shareware Plus / Development / Akua Sweets 131 / Akua Sweets Examples / System / Date Stuff < prev    next >
Encoding:
Text File  |  1999-03-04  |  2.8 KB  |  73 lines  |  [TEXT/ToyS]

  1. property kdtPeriod : 0 -- Puts a '.' in there - you can replace it with what you want
  2. property kdtYearLong : 1 -- 1904-2020
  3. property kdtYear : 2 -- 00-99
  4. property kdtMonth : 3 -- 01-12
  5. property kdtMonthVar : 4 -- 1-12
  6. property kdtDay : 5 -- 01-31
  7. property kdtDayVar : 6 -- 1-31
  8. property kdtHour : 7 -- 00-23
  9. property kdtHourVar : 8 -- 0-23, empty if first item and followed by colon
  10. property kdtMinute : 9 -- 00-59
  11. property kdtSecond : 10 -- 00-59
  12. property kdtTicks : 11 -- 00-59
  13. property kdtText : 12 -- Not supported (Next nibble is done in text mode (Sun-Sat or Jan-Dec))
  14. property kdtTextFull : 13 -- Not supported (Next nibble is done in full text mode (Sunday-Saturday or January-December))
  15. property kdtColon : 14 -- ':' delimeter
  16. property kdtSlash : 15 -- '/' delimeter
  17.  
  18.  
  19.  
  20. on run
  21.     -- Try for last Sunday of March, 1998
  22.     display dialog "The date of the last Sunday in March, 1998 is: " & ¬
  23.         (the clock using nth {-1, 1, 3, 98})
  24.     
  25.     -- Try for second Monday of September, 2000 (I turn 33 :)
  26.     display dialog "The date of the second Monday in September, 2000 is: " & ¬
  27.         (the clock using nth {2, 2, 9, 2000})
  28.     
  29.     -- Create "MM/DD/YY" - note the reverse order
  30.     set myFormat to 0
  31.     set myFormat to dtAddItem(myFormat, kdtYear)
  32.     set myFormat to dtAddItem(myFormat, kdtSlash)
  33.     set myFormat to dtAddItem(myFormat, kdtDay)
  34.     set myFormat to dtAddItem(myFormat, kdtSlash)
  35.     set myFormat to dtAddItem(myFormat, kdtMonth)
  36.     
  37.     display dialog "Created date: " & (the clock using format myFormat) & ¬
  38.         return & return & "Using: " & myFormat ¬
  39.         buttons {"OK"} default button 1
  40.     
  41.     -- Create "MM/DD HH:MM" - note the reverse order
  42.     set myFormat to 0
  43.     set myFormat to dtAddItem(myFormat, kdtSecond)
  44.     set myFormat to dtAddItem(myFormat, kdtColon)
  45.     set myFormat to dtAddItem(myFormat, kdtHour)
  46.     set myFormat to dtAddItem(myFormat, kdtPeriod) -- creates ' ' since slash is used below
  47.     set myFormat to dtAddItem(myFormat, kdtDay)
  48.     set myFormat to dtAddItem(myFormat, kdtSlash)
  49.     set myFormat to dtAddItem(myFormat, kdtMonth)
  50.     
  51.     display dialog "Created date: " & (the clock using format myFormat) & ¬
  52.         return & return & "Using: " & myFormat ¬
  53.         buttons {"OK"} default button 1
  54.     
  55.     -- Create "DD.MM HH:MM" - note the reverse order
  56.     set myFormat to 0
  57.     set myFormat to dtAddItem(myFormat, kdtSecond)
  58.     set myFormat to dtAddItem(myFormat, kdtColon)
  59.     set myFormat to dtAddItem(myFormat, kdtHour)
  60.     set myFormat to dtAddItem(myFormat, kdtSlash) -- creates ' ' since period is used below
  61.     set myFormat to dtAddItem(myFormat, kdtMonth)
  62.     set myFormat to dtAddItem(myFormat, kdtPeriod)
  63.     set myFormat to dtAddItem(myFormat, kdtDay)
  64.     
  65.     display dialog "Created date: " & (the clock using format myFormat) & ¬
  66.         return & return & "Using: " & myFormat ¬
  67.         buttons {"OK"} default button 1
  68. end run
  69.  
  70.  
  71. on dtAddItem(dateFormat, newAddition)
  72.     return dateFormat * 16 + newAddition
  73. end dtAddItem